/**
 * Copyright � 2008-2009 Paul van Santen
 *
 * This file is part of EVEMap.
 *
 * EVEMap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * EVEMap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with EVEMap; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * http://www.gnu.org/licenses/gpl.txt
**/

package net.vansante.EVEMap.UI;

import java.awt.*;
import javax.swing.*;

import net.vansante.EVEMap.Constants;
import net.vansante.EVEMap.UI.Menus.Menubar;

public class Sidebar extends JPanel {
	
	private final Menubar menu;
	private final SearchPanel search;
	private final RoutePanel route;
	private final RouteSettingsPanel routeSettings;
	private final MapSettingsPanel mapSettings;
        private final TradePanel trade;
	
	private final JTabbedPane tabPane;
	
	public Sidebar() {
		this.setMinimumSize(new Dimension(Constants.SIDEBAR_WIDTH, 500));
		this.setMaximumSize(new Dimension(Constants.SIDEBAR_WIDTH, 500));
		this.setLayout(new BorderLayout());
		
		menu = new Menubar(); 
		this.add(menu, BorderLayout.NORTH);
		
		search = new SearchPanel();
		route = new RoutePanel();
		routeSettings = new RouteSettingsPanel();
		mapSettings = new MapSettingsPanel();
                trade = new TradePanel();
		
		tabPane = new JTabbedPane();
		tabPane.addTab("Map settings", mapSettings);
		tabPane.addTab("Route settings", routeSettings);
		tabPane.addTab("Route", route);
		tabPane.addTab("Search", search);
                tabPane.addTab("Trade", trade);
		
		this.add(tabPane, BorderLayout.CENTER);
	}
	public RoutePanel getRoutePanel() {
		return route;
	}
	public RouteSettingsPanel getRouteSettingsPanel() {
		return routeSettings;
	}
	public static JPanel createBorderedPanel(JPanel target, String title, int width, int height) {
		return createBorderedPanel(target, title, width, height, false);
	}
	public static JPanel createBorderedPanel(JPanel target, String title, int width, int height, boolean scale) {
		JPanel panel = new JPanel(new GridLayout(1, 1, 1, 1));
		if (title != null) {
			panel.setBorder(BorderFactory.createTitledBorder(title));
		}
		if (!scale) {
			panel.setMinimumSize(new Dimension(width, height));
			panel.setMaximumSize(new Dimension(width, height));
			panel.setPreferredSize(new Dimension(width, height));
		}
		target.add(panel);
		JPanel subPanel = new JPanel();
		panel.add(subPanel);
		return subPanel;
	}
        
        public TradePanel getTradePanel()
        {
            return trade;
        }
}
